package com.fira.api.controller;

import com.fira.api.domain.dto.LoginDTO;
import com.fira.common.core.controller.BaseController;
import com.fira.common.core.domain.AjaxResult;
import com.fira.common.utils.StringUtils;
import com.fira.edu.domain.dto.parent.ParentStudentsDTO;
import com.fira.edu.domain.dto.parent.StudentCourseDTO;
import com.fira.edu.service.IEduParentService;
import com.fira.edu.service.IEduStudentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * 小程序家长中心接口
 * @author: tony
 * @description:
 * @date: 2021-10-12
 */
@Api(value="家长中心接口",tags={"家长中心"})
@Controller
@RequestMapping("/api/parent")
public class ParentController extends ApiController {
    @Autowired
    private IEduParentService eduParentService;
    @Autowired
    private IEduStudentService eduStudentService;

    @ApiOperation(value="查询在读学生列表",tags={"查询在读学生列表"},notes="")
    @PostMapping("/list")
    @ResponseBody
    public AjaxResult getParentStudents(@ApiParam(name="查询入参",value = "parentStudentsDTO")
                                            @Valid ParentStudentsDTO parentStudentsDTO, HttpServletRequest request){
        LoginDTO loginDTO = getLogin(request);
        String parentId = loginDTO.getParentId();
        if(StringUtils.isEmpty(parentId)){
            return AjaxResult.success("查询成功",null);
        }
        parentStudentsDTO.setParentId(parentId);
        return AjaxResult.success("查询成功",eduParentService.selectParentStudents(parentStudentsDTO));
    }

    @ApiOperation(value="查询学生课程明细列表",tags={"查询在学生课程明细列表"},notes="")
    @PostMapping("/studentCourseList")
    @ResponseBody
    public AjaxResult getStudentCourseList(@ApiParam(name = "学生课程明细入参",value = "studentCourseDTO") @Valid StudentCourseDTO studentCourseDTO, HttpServletRequest request){
        LoginDTO loginDTO = getLogin(request);
        String tenantId = loginDTO.getCurrentTenantId();
        studentCourseDTO.setTenantId(tenantId);
        return AjaxResult.success("查询成功",eduStudentService.selectStudentCourses(studentCourseDTO));
    }
}
